import java.awt.event.ActionEvent;
import java.awt.geom.Rectangle2D;


public class rect{
	int id = -1;
	
	int x = 10;
	int y = 50;
	
	int width;
	int height;
	
	int speed;

	boolean up = false;
	boolean down = false;
	boolean left = false;
	boolean right = false;
	
	boolean paused = false;
	
	Rectangle2D.Double rectObject;
	
	public rect(int xP, int yP, int w, int h, int s)
	{
		x = xP;
		y = yP;
		width = w;
		height = h;
		speed = s;
		rectObject = new Rectangle2D.Double(x, y, w, h);
	}

	public rect()
	{
		
	}
	
	public void update(int w, int h)
	{	
		//Do key actions
		if(right)
		{
			x = x + speed;
		}
		if(left)
		{
			x = x - speed;
		}
		if(up)
		{
			y = y - speed;
		}
		if(down)
		{
			y = y + speed;
		}
		
		if(x > (w - width))
		{
			x = (w - height) - 3;
		}
		else if(x < 0)
		{
			x = 3;
		}
		else if(y > (h - height))
		{
			y = (h - height) - 3;
		}
		else if(y < 0)
		{
			y = 3;
		}
		
		rectObject.setRect(x, y, width, height);
	}
	
	public void update(Rectangle2D.Double r, int w, int h)
	{
		if(x > r.x)
		{
			x = x - speed;
		}
		else if(x < r.x)
		{
			x = x + speed;
		}
		
		if(y > r.y)
		{
			y = y - speed;
		}
		else if(y < r.y)
		{
			y = y + speed;
		}

		if(x > (w - width))
		{
			x = (w - width) - 3;
		}
		else if(x < 0)
		{
			x = 3;
		}
		else if(y > (h - height))
		{
			y = (h - height) - 3;
		}
		else if(y < 0)
		{
			y = 3;
		}
		
		rectObject.setRect(x, y, width, height);
	}
	
	public int hashCode()
	{
		return id;
	}
}
